<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Section 13.4.&nbsp; Error Logging</title>
<link rel="STYLESHEET" type="text/css" href="images/style.css">
<link rel="STYLESHEET" type="text/css" href="images/docsafari.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch13lev1sec3.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch13lev1sec5.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><a name="ch13lev1sec4"></a>
<h3 class="docSection1Title">13.4. Error Logging</h3>
<p class="docText"><a name="idd1e95679"></a><a name="idd1e95684"></a><a name="idd1e95689"></a><a name="idd1e95694"></a><a name="idd1e95699"></a><a name="idd1e95704"></a><a name="idd1e95709"></a><a name="idd1e95714"></a><a name="idd1e95719"></a><a name="idd1e95724"></a><a name="idd1e95729"></a><a name="idd1e95732"></a><a name="idd1e95737"></a><a name="idd1e95742"></a><a name="idd1e95747"></a><a name="idd1e95752"></a><a name="idd1e95757"></a><a name="idd1e95762"></a><a name="idd1e95767"></a><a name="idd1e95772"></a><a name="idd1e95777"></a><a name="idd1e95782"></a><a name="idd1e95787"></a><a name="idd1e95790"></a><a name="idd1e95795"></a><a name="idd1e95800"></a><a name="idd1e95805"></a><a name="idd1e95808"></a><a name="idd1e95811"></a><a name="idd1e95816"></a><a name="idd1e95821"></a>One problem a daemon has is how to handle error messages. It can't simply write to standard error, since it shouldn't have a controlling terminal. We don't want all the daemons writing to the console device, since on many workstations, the console device runs a windowing system. We also don't want each daemon writing its own error messages into a separate file. It would be a headache for anyone administering the system to keep up with which daemon writes to which log file and to check these files on a regular basis. A central daemon error-logging facility is required.</P>
<blockquote>
<p class="docText">The BSD <tt>syslog</tt> facility was developed at Berkeley and used widely in 4.2BSD. Most systems derived from BSD support <tt>syslog</tt>.</P>
<p class="docText">Until SVR4, System V never had a central daemon logging facility.</p>
<p class="docText">The <tt>syslog</tt> function is included as an XSI extension in the Single UNIX Specification.</P>
</blockquote>
<p class="docText"><a name="idd1e95849"></a><a name="idd1e95854"></a><a name="idd1e95859"></a><a name="idd1e95864"></a><a name="idd1e95867"></a><a name="idd1e95872"></a><a name="idd1e95877"></a><a name="idd1e95880"></a><a name="idd1e95883"></a>The BSD <tt>syslog</tt> facility has been widely used since 4.2BSD. Most daemons use this facility. <a class="docLink" href="#ch13fig02">Figure 13.2</a> illustrates its structure.</P>
<a name="ch13fig02"></a><P><center>
<h5 class="docFigureTitle">Figure 13.2. The BSD <tt>syslog</tt> facility</H5>

<p class="docText">
<img border="0" alt="" width="488" height="390" SRC="images/0201433079/graphics/13fig02.gif;423615"></P>

</center></P><br>
<p class="docText">There are three ways to generate log messages:</P>
<div style="font-weight:bold"><ol class="docList" type="1"><li><div style="font-weight:normal"><p class="docList">Kernel routines can call the <tt>log</tt> function. These messages can be read by any user process that <tt>open</tt>s and <tt>read</tt>s the <tt>/dev/klog</tt> device. We won't describe this function any further, since we're not interested in writing kernel routines.</P></div></LI><LI><div style="font-weight:normal"><p class="docList">Most user processes (daemons) call the <tt>syslog</tt>(3) function to generate log messages. We describe its calling sequence later. This causes the message to be sent to the UNIX domain datagram socket <tt>/dev/log</tt>.</p></div></LI><LI><div style="font-weight:normal"><p class="docList">A user process on this host, or on some other host that is connected to this host by a TCP/IP network, can send log messages to UDP port 514. Note that the <tt>syslog</tt> function never generates these UDP datagrams: they require explicit network programming by the process generating the log message.</p></div></LI></ol></div>
<p class="docText">Refer to Stevens, Fenner, and Rudoff [<a class="docLink" href="bib01.html#biblio01_059">2004</a>] for details on UNIX domain sockets and UDP sockets.</P>
<p class="docText">Normally, the <tt>syslogd</tt> daemon reads all three forms of log messages. On start-up, this daemon reads a configuration file, usually <tt>/etc/syslog.conf</tt>, which determines where different classes of messages are to be sent. For example, urgent messages can be sent to the system administrator (if logged in) and printed on the console, whereas warnings may be logged to a file.</p>
<p class="docText"><a name="idd1e95974"></a><a name="idd1e95979"></a><a name="idd1e95986"></a><a name="idd1e95991"></a><a name="idd1e95996"></a><a name="idd1e96001"></a><a name="idd1e96006"></a><a name="idd1e96011"></a><a name="idd1e96016"></a><a name="idd1e96021"></a><a name="idd1e96026"></a><a name="idd1e96033"></a><a name="idd1e96038"></a><a name="idd1e96045"></a><a name="idd1e96050"></a><a name="idd1e96053"></a><a name="idd1e96056"></a><a name="idd1e96063"></a><a name="idd1e96068"></a>Our interface to this facility is through the <tt>syslog</tt> function.</p>
<a name="inta293"></a><p><table cellspacing="0" class="allBorders" border="1" RULES="none" cellpadding="5"><colgroup><col width="500"></colgroup><thead></thead><tr><TD class="docTableCell" align="left" valign="top"><p class="docText">
<a name="PLID0"></a><div class="v1"><a href="ch13lev1sec4.html#PLID0">[View full width]</a></div><pre>
#include &lt;syslog.h&gt;

void openlog(const char *<span class="docEmphItalicAlt">ident</span>, int <span class="docEmphItalicAlt">option</span>, int
<img border="0" width="14" height="9" alt="" align="left" src="images/ccc.gif"> <span class="docEmphItalicAlt">facility</span>);

void syslog(int <span class="docEmphItalicAlt">priority</span>, const char *<span class="docEmphItalicAlt">format</span>, ...);

void closelog(void);

int setlogmask(int <span class="docEmphasis">maskpri</span>);
</pre><br>
</P></td></TR><tr><td class="docTableCell" align="right" valign="top"><p class="docText">Returns: previous log priority mask value</p></td></tr></table></p><br>
<p class="docText">Calling <tt>openlog</tt> is optional. If it's not called, the first time <tt>syslog</tt> is called, <tt>openlog</tt> is called automatically. Calling <tt>closelog</tt> is also optionalit just closes the descriptor that was being used to communicate with the <tt>syslogd</tt> daemon.</p>
<p class="docText">Calling <tt>openlog</tt> lets us specify an <span class="docEmphasis">ident</span> that is added to each log message. This is normally the name of the program (<tt>cron</tt>, <tt>inetd</tt>, etc.). The <span class="docEmphasis">option</span> argument is a bitmask specifying various options. <a class="docLink" href="#ch13fig03">Figure 13.3</a> describes the available options, including a bullet in the XSI column if the option is included in the <tt>openlog</tt> definition in the Single UNIX Specification.</p>
<a name="ch13fig03"></a><p><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><h5 class="docTableTitle">Figure 13.3. The <span class="docEmphasis">option</span> argument for <tt>openlog</tt></h5></caption><colgroup><col width="70"><col width="30"><col width="400"></colgroup><thead><tr><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="top"><p class="docText"><span class="docEmphRoman"><span class="docEmphasis">option</span></span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="top"><p class="docText"><span class="docEmphRoman">XSI</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="top"><p class="docText"><span class="docEmphRoman">Description</span></p></th></tr></thead><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_CONS</tt></p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">If the log message can't be sent to <tt>syslogd</tt> via the UNIX domain datagram, the message is written to the console instead.</P></TD></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_NDELAY</tt></P></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">Open the UNIX domain datagram socket to the <tt>syslogd</tt> daemon immediately; don't wait until the first message is logged. Normally, the socket is not opened until the first message is logged.</p></TD></TR><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_NOWAIT</tt></p></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">Do not wait for child processes that might have been created in the process of logging the message. This prevents conflicts with applications that catch <tt>SIGCHLD</tt>, since the application might have retrieved the child's status by the time that <tt>syslog</tt> calls <tt>wait</tt>.</P></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_ODELAY</tt></p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">Delay the open of the connection to the <tt>syslogd</tt> daemon until the first message is logged.</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_PERROR</tt></p></td><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="left" valign="top"><p class="docText">Write the log message to standard error in addition to sending it to <tt>syslogd</tt>. (Unavailable on Solaris.)</P></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_PID</tt></P></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">Log the process ID with each message. This is intended for daemons that <tt>fork</tt> a child process to handle different requests (as compared to daemons, such as <tt>syslogd</tt>, that never call <tt>fork</tt>).</P></TD></tr></table></P><BR>
<p class="docText">The <span class="docEmphasis">facility</span> argument for <tt>openlog</tt> is taken from <a class="docLink" href="#ch13fig04">Figure 13.4</a>. Note that the Single UNIX Specification defines only a subset of the facility codes typically available on a given platform. The reason for the <span class="docEmphasis">facility</span> argument is to let the configuration file specify that messages from different facilities are to be handled differently. If we don't call <tt>openlog</tt>, or if we call it with a <span class="docEmphasis">facility</span> of 0, we can still specify the facility as part of the <span class="docEmphasis">priority</span> argument to <tt>syslog</tt>.</p>
<a name="ch13fig04"></a><P><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><H5 class="docTableTitle">Figure 13.4. The <span class="docEmphasis">facility</span> argument for <tt>openlog</tt></h5></caption><colgroup><col width="100"><col width="50"><col width="350"></colgroup><thead><tr><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="top"><p class="docText"><span class="docEmphRoman"><span class="docEmphasis">facility</span></span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="top"><p class="docText"><span class="docEmphRoman">XSI</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="top"><p class="docText"><span class="docEmphRoman">Description</span></P></th></tr></thead><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_AUTH</tt></P></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top"><p class="docText">authorization programs: <tt>login, su, getty</tt>, ...</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_AUTHPRIV</tt></p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top"><p class="docText">same as <tt>LOG_AUTH</tt>, but logged to file with restricted permissions</p></td></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_CRON</tt></p></TD><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>cron</tt> and <tt>at</tt></P></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_DAEMON</tt></p></TD><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="left" valign="top"><p class="docText">system daemons: <tt>inetd, routed,</tt> ...</P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_FTP</tt></p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top"><p class="docText">the FTP daemon (<tt>ftpd</tt>)</p></TD></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_KERN</tt></p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top"><p class="docText">messages generated by the kernel</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_LOCAL0</tt></p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">reserved for local use</P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_LOCAL1</tt></P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">reserved for local use</P></td></TR><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_LOCAL2</tt></p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">reserved for local use</p></td></tr><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_LOCAL3</tt></p></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="docTableCell" align="left" valign="top"><p class="docText">reserved for local use</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_LOCAL4</tt></p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">reserved for local use</p></td></tr><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_LOCAL5</tt></P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">reserved for local use</P></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_LOCAL6</tt></p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">reserved for local use</P></td></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_LOCAL7</tt></p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">reserved for local use</p></TD></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_LPR</tt></p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top"><p class="docText">line printer system: <tt>lpd, lpc</tt>, ...</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_MAIL</tt></p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top"><p class="docText">the mail system</P></td></TR><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_NEWS</tt></p></TD><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="left" valign="top"><p class="docText">the Usenet network news system</P></td></TR><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_SYSLOG</tt></p></TD><TD class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top"><p class="docText">the <tt>syslogd</tt> daemon itself</P></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_USER</tt></P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">messages from other user processes (default)</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_UUCP</tt></p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top"><p class="docText">the UUCP system</p></td></tr></table></p><br>
<p class="docText"><a name="idd1e96731"></a><a name="idd1e96736"></a><a name="idd1e96741"></a><a name="idd1e96746"></a><a name="idd1e96751"></a><a name="idd1e96756"></a><a name="idd1e96761"></a><a name="idd1e96766"></a><a name="idd1e96771"></a><a name="idd1e96776"></a><a name="idd1e96781"></a><a name="idd1e96786"></a><a name="idd1e96791"></a><a name="idd1e96796"></a><a name="idd1e96801"></a><a name="idd1e96806"></a><a name="idd1e96811"></a><a name="idd1e96816"></a><a name="idd1e96821"></a><a name="idd1e96826"></a><a name="idd1e96831"></a><a name="idd1e96836"></a><a name="idd1e96841"></a><a name="idd1e96846"></a><a name="idd1e96851"></a><a name="idd1e96856"></a><a name="idd1e96861"></a><a name="idd1e96866"></a><a name="idd1e96871"></a><a name="idd1e96876"></a><a name="idd1e96881"></a><a name="idd1e96886"></a><a name="idd1e96891"></a><a name="idd1e96896"></a><a name="idd1e96901"></a><a name="idd1e96906"></a><a name="idd1e96911"></a><a name="idd1e96916"></a>We call <tt>syslog</tt> to generate a log message. The <span class="docEmphasis">priority</span> argument is a combination of the <span class="docEmphasis">facility</span> shown in <a class="docLink" href="#ch13fig04">Figure 13.4</a> and a <span class="docEmphasis">level</span>, shown in <a class="docLink" href="#ch13fig05">Figure 13.5</a>. These <span class="docEmphasis">level</span>s are ordered by priority, from highest to lowest.</p>
<a name="ch13fig05"></a><P><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><H5 class="docTableTitle">Figure 13.5. The <tt>syslog</tt> <span class="docEmphasis">level</span>s (ordered)</h5></caption><colgroup><col width="100"><col width="400"></colgroup><thead><TR><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="top"><p class="docText"><span class="docEmphRoman"><span class="docEmphasis">level</span></span></P></th><th class="bottomBorder thead" scope="col" align="center" valign="top"><p class="docText"><span class="docEmphRoman">Description</span></P></th></tr></thead><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_EMERG</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">emergency (system is unusable) (highest priority)</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_ALERT</tt></P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">condition that must be fixed immediately</P></TD></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_CRIT</tt></p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">critical condition (e.g., hard device error)</P></td></TR><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_ERR</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">error condition</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_WARNING</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText">warning condition</p></td></tr><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_NOTICE</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">normal, but significant condition</P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_INFO</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">informational message</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>LOG_DEBUG</tt></P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">debug message (lowest priority)</P></TD></tr></table></p><br>
<p class="docText">The <span class="docEmphasis">format</span> argument and any remaining arguments are passed to the <tt>vsprintf</tt> function for formatting. Any occurrence of the two characters <tt>%m</tt> in the <span class="docEmphasis">format</span> are first replaced with the error message string (<tt>strerror</tt>) corresponding to the value of <tt>errno</tt>.</p>
<p class="docText">The <tt>setlogmask</tt> function can be used to set the log priority mask for the process. This function returns the previous mask. When the log priority mask is set, messages are not logged unless their priority is set in the log priority mask. Note that attempts to set the log priority mask to 0 will have no effect.</P>
<p class="docText"><a name="idd1e97112"></a><a name="idd1e97117"></a><a name="idd1e97122"></a><a name="idd1e97125"></a><a name="idd1e97128"></a><a name="idd1e97133"></a><a name="idd1e97138"></a>The <tt>logger</tt>(1) program is also provided by many systems as a way to send log messages to the <tt>syslog</tt> facility. Some implementations allow optional arguments to this program, specifying the <span class="docEmphasis">facility</span>, <span class="docEmphasis">level</span>, and <span class="docEmphasis">ident</span>, although the Single UNIX Specification doesn't define any options. The <tt>logger</tt> command is intended for a shell script running noninteractively that needs to generate log messages.</p>
<a name="ch13ex02"></a>
<H5 class="docExampleTitle">Example</h5>
<p class="docText">In a (hypothetical) line printer spooler daemon, you might encounter the sequence</P>

<pre>
   openlog("lpd", LOG_PID, LOG_LPR);
   syslog(LOG_ERR, "open error for %s: %m", filename);
</pre><br>

<p class="docText">The first call sets the <span class="docEmphasis">ident</span> string to the program name, specifies that the process ID should always be printed, and sets the default <span class="docEmphasis">facility</span> to the line printer system. The call to <tt>syslog</tt> specifies an error condition and a message string. If we had not called <tt>openlog</tt>, the second call could have been</p>

<pre>
   syslog(LOG_ERR | LOG_LPR, "open error for %s: %m", filename);
</pre><br>

<p class="docText">Here, we specify the <span class="docEmphasis">priority</span> argument as a combination of a <span class="docEmphasis">level</span> and a <span class="docEmphasis">facility</span>.</p>

<p class="docText">In addition to <tt>syslog</tt>, many platforms provide a variant that handles variable argument lists.</p>
<a name="inta374"></a><p><table cellspacing="0" class="allBorders" border="1" RULES="none" cellpadding="5"><colgroup><col width="500"></colgroup><thead></thead><tr><td class="docTableCell" align="left" valign="top"><p class="docText">
<a name="PLID3"></a><div class="v1"><a href="ch13lev1sec4.html#PLID3">[View full width]</a></div><pre>
#include &lt;syslog.h&gt;
#include &lt;stdarg.h&gt;

void vsyslog(int <span class="docEmphItalicAlt">priority</span>, const char *<span class="docEmphItalicAlt">format</span>,
<img border="0" width="14" height="9" alt="" align="left" src="images/ccc.gif"> va_list <span class="docEmphItalicAlt">arg</span>);
</pre><br>

</p></td></tr></table></p><br>
<blockquote>
<p class="docText">All four platforms described in this book provide <tt>vsyslog</tt>, but it is not included in the Single UNIX Specification.</p>
</blockquote>
<p class="docText">Most <tt>syslogd</tt> implementations will queue messages for a short time. If a duplicate message arrives during this time, the <tt>syslog</tt> daemon will not write it to the log. Instead, the daemon will print out a message similar to &quot;last message repeated <span class="docEmphasis">N</span> times.&quot;</p>

<a href="17021535.html"><img src="images/pixel.gif" alt="" width="1" height="1" border="0"></a><ul></UL></TD></tr></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch13lev1sec3.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch13lev1sec5.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
</body></html><br>
<table width="100%" cellspacing="0" cellpadding="0"
style="margin-top: 0pt; border-collapse: collapse;"> 
<tr> <td align="right" style="background-color=white; border-top: 1px solid gray;"> 
<a href="http://www.zipghost.com/" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">The CHM file was converted to HTM by Trial version of <b>ChmD<!--227-->ecompiler</b>.</a>
</TD>
</TR><tr>
<td align="right" style="background-color=white; "> 
<a href="http://www.etextwizard.com/download/cd/cdsetup.exe" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">Download <b>ChmDec<!--227-->ompiler</b> at: http://www.zipghost.com</a>
</TD></tr></table>
